<script setup lang="ts">
import {User, HomeFilled, ChatDotRound,View} from "@element-plus/icons-vue";
import {useRouter} from "vue-router";
import {ElMessageBox} from "element-plus";
import userUser from "../../store/user.ts";

const router = useRouter();
// 消息
const mail = () => {
  router.push("/Mail")
}
// 个人中心
const mine = () => {
  router.push("/Me")
}
// 显示酒店信息
const hotelManage = () => {
  router.push("/Hotel")
}
// 角色管理
const roleManage = () =>{
  router.push("/rolePlat")
}
// 用户管理
const userManage = () =>{
  router.push("/userPlat")
}
// 加盟审核
const franchiseExam = () =>{
  router.push("/Franchise")
}
// 酒店审核
const hotelExam = () =>{
  router.push("/HotelExam")
}
// 房型审核
const roomTypeExam = () =>{
  router.push("/RoomTypeExam")
}
// 退出系统
let userStore = userUser()
const exit = () => {
  ElMessageBox.confirm(
      '确定退出系统吗？',
      '系统提示',
      {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning'
      }
  )
      .then(() => {
        userStore.clearUser()
        router.push('/')
      })
      .catch(() => {

      })
}
</script>

<template>
  <div class="common-layout">
    <el-container>
      <el-header class="common-header">
        <el-col :span="4"><h2>协同后台管理</h2></el-col>
        <el-col
            :span="1"
            :push="7"
            align="middle"
            @click="mail"
        >
          <el-icon>
            <ChatDotRound/>
          </el-icon>
        </el-col>
        <el-col :span="4">
          <el-dropdown>
            <span class="el-dropdown-link">
              <el-icon class="el-icon--right"><User/></el-icon>
              管理员
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click="mine">个人中心</el-dropdown-item>
                <el-dropdown-item @click="exit">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </el-col>
      </el-header>
      <el-container>
        <el-aside width="200px" class="aside">
          <el-menu
              default-active="2"
              class="el-menu-vertical-demo"
              mode="vertical"
          >
            <!--用户管理-->
            <el-sub-menu index="1">
              <template #title>
                <el-icon>
                  <User/>
                </el-icon>
                <span>账户管理</span>
              </template>
              <el-menu-item index="/role" @click="roleManage">角色管理</el-menu-item>
              <el-menu-item index="/user" @click="userManage">用户管理</el-menu-item>
            </el-sub-menu>
            <!--酒店管理-->
            <el-menu-item index="/hotel" @click="hotelManage">
              <template #title>
                <el-icon>
                  <HomeFilled/>
                </el-icon>
                <span>酒店管理</span>
              </template>
            </el-menu-item>
            <!--审核-->
            <el-sub-menu index="3">
              <template #title>
                <el-icon><View /></el-icon>
                <span>审核</span>
              </template>
              <el-menu-item index="franchise" @click="franchiseExam">加盟审核</el-menu-item>
              <el-menu-item index="hotelExam" @click="hotelExam">酒店审核</el-menu-item>
              <el-menu-item index="roomExam" @click="roomTypeExam">房间审核</el-menu-item>
            </el-sub-menu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style scoped lang="scss">
.common-header {
  font-family: gong;
  background-color: #C9D1F8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.aside{
  height: 100vh;
}
.el-menu-vertical-demo, .aside {
  font-family: gong;
  background-color: #cad4f8;
}
</style>